<template>
   <div>
       <div class="toolbar">
           <el-button type="success"
           @click="goodsTypeVisible=true"
           >添加职位
           </el-button>
       </div>
       <el-table
               v-loading="$store.state.isLoading"
               :border="true"
               :data="$store.state.goods.goodsTypeList"
               style="width: 100%">
           <el-table-column label="职位ID" width="250">
               <template slot-scope="scope">
                   {{scope.row._id}}
               </template>
           </el-table-column>
           <el-table-column
                   label="上传日期"
                   width="200">
               <template slot-scope="scope">
                   <i class="el-icon-time"></i>
                   <span style="margin-left: 10px">{{ scope.row.createTime | date }}</span>
               </template>
           </el-table-column>
           <el-table-column label="职位名称">
               <template slot-scope="scope">
                   {{scope.row.goodsTypeName}}
               </template>
           </el-table-column>
           <el-table-column label="所属部门">
               <template slot-scope="scope">
                   {{scope.row.shopTypeName}}
               </template>
           </el-table-column>
           <el-table-column label="所属组">
               <template slot-scope="scope">
                   {{scope.row.shopName}}
               </template>
           </el-table-column>

           <el-table-column label="操作">
               <template slot-scope="scope">

                   <!--<el-button size="mini" type="success" @click="$router.push({name:'GoodsList',params:{goodsTypeId:scope.row._id}})">查看本类别商品</el-button>-->
                   <el-button size="mini" type="success" @click="shopTypeId=scope.row._id;shopListVisible=true;">添加员工信息</el-button>
                   <el-button size="mini" type="danger" @click="deleteOne(scope.row._id)">删除</el-button>
               </template>
           </el-table-column>
       </el-table>

       <GoodsTypeDialog v-if="goodsTypeVisible" :visible.sync="goodsTypeVisible">

           </GoodsTypeDialog>
       <PageInfo actions-name="getGoodsTypeList"></PageInfo>
   </div>
</template>

<script>
    export default {
        name: "GoodsTypeList",
        data(){
            return {
                goodsTypeVisible:false,
                goodsTypeId:"",
            }
        },
        mounted(){
            this.$store.dispatch("getGoodsTypeList")
        },
        methods:{
            async deleteOne(id){
                const path = this.$route.path
                const data = await this.$store.dispatch("deleteOneById",{id,path})
                if(data.ok ===1)
                    this.$store.dispatch("getGoodsTypeList")
            }
        }
    }
</script>

<style scoped>

</style>